<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="组织架构" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="addSubNode(root)"
                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">新增</button>
                </div>
            </div>
            <div class="main-area d-b-15">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table border-none">
                            <thead>
                            <tr>
                                <th width="75%" translate>部门名称</th>
                                <th width="25%" translate>操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="root.children.length > 0">
                        <table class="table border-none">
                            <tbody ng-repeat="parentDepart in root.children track by $index" class="border-none">
                            <tr>
                                <td width="75%" class="spill-dots" title="{{parentDepart.name}}">
                                    <i ng-if="parentDepart.isParent" class="yb-icon m-r-xs cursor-pointer"
                                       ng-class="{'ico-minus-square-o':parentDepart.isExpand, 'ico-plus-square-o':!parentDepart.isExpand}"
                                       ng-click="parentDepart.isExpand = !parentDepart.isExpand;getChildData(parentDepart)"></i>
                                    {{parentDepart.name}}
                                </td>
                                <td width="25%" class="font-0">
                                    <button class="btn btn-operate m-r-xs" ng-click="editData(parentDepart, root)"
                                            ng-disabled="!btnPermission.organizeEdit" translate translate-attr-title="{{!btnPermission.organizeEdit?'无权限执行此操作':''}}">编辑</button>
                                    <button class="btn btn-operate m-r-xs" ng-click="delData(root, $index)"
                                            ng-disabled="!btnPermission.organizeDel" translate translate-attr-title="{{!btnPermission.organizeDel?'无权限执行此操作':''}}">删除</button>
                                    <button class="btn btn-operate m-r-xs" ng-click="addSubNode(parentDepart)"
                                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">添加下级</button>
                                    <button class="btn btn-operate" ng-click="configWarehouse(parentDepart)"
                                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">配置仓库</button>
                                </td>
                            </tr>
                            <tr ng-repeat-start="childDepart in parentDepart.children track by $index" ng-if="parentDepart.isExpand">
                                <td class="spill-dots p-l-xl" title="{{childDepart.name}}">
                                    <i ng-if="childDepart.isParent" class="yb-icon m-r-xs cursor-pointer"
                                       ng-class="{'ico-minus-square-o':childDepart.isExpand, 'ico-plus-square-o':!childDepart.isExpand}"
                                       ng-click="childDepart.isExpand = !childDepart.isExpand;getChildData(childDepart)"></i>
                                    {{childDepart.name}}
                                </td>
                                <td class="font-0">
                                    <button class="btn btn-operate m-r-xs" ng-click="editData(childDepart,parentDepart)"
                                            ng-disabled="!btnPermission.organizeEdit" translate translate-attr-title="{{!btnPermission.organizeEdit?'无权限执行此操作':''}}">编辑</button>
                                    <button class="btn btn-operate m-r-xs" ng-click="delData(parentDepart, $index)"
                                            ng-disabled="!btnPermission.organizeDel" translate translate-attr-title="{{!btnPermission.organizeDel?'无权限执行此操作':''}}">删除</button>
                                    <button class="btn btn-operate m-r-xs" ng-click="addSubNode(childDepart)"
                                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">添加下级</button>
                                    <button class="btn btn-operate" ng-click="configWarehouse(childDepart)"
                                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">配置仓库</button>
                                </td>
                            </tr>
                            <tr ng-repeat-end ng-repeat="sonDepart in childDepart.children track by $index"
                                ng-if="childDepart.isExpand && parentDepart.isExpand" >
                                <td class="spill-dots p-l-xxxl" title="{{sonDepart.name}}">
                                    {{sonDepart.name}}
                                </td>
                                <td class="font-0">
                                    <button class="btn btn-operate m-r-xs" ng-click="editData(sonDepart,childDepart)"
                                            ng-disabled="!btnPermission.organizeEdit" translate translate-attr-title="{{!btnPermission.organizeEdit?'无权限执行此操作':''}}">编辑</button>
                                    <button class="btn btn-operate m-r-xs" ng-click="delData(childDepart, $index)"
                                            ng-disabled="!btnPermission.organizeDel" translate translate-attr-title="{{!btnPermission.organizeDel?'无权限执行此操作':''}}">删除</button>
                                    <button class="btn btn-operate" ng-click="configWarehouse(sonDepart)"
                                            ng-disabled="!btnPermission.organizeAdd" translate translate-attr-title="{{!btnPermission.organizeAdd?'无权限执行此操作':''}}">配置仓库</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="root.children.length === 0" translate>暂时没有数据</div>
                </div>
            </div>
        </div>
        <div tab heading="{{tabFlag.name}}" active="activeFlag[1]" ng-if="activeFlag[1]">
            <div class="main-area d-t-35 d-b-60">
                <form name="form" class="main-wrap form-horizontal single-col p-t clearfix" novalidate>
                    <div class="form-group" ng-if="detailInfo.parentNodeName !== ''">
                        <label class="col-xs-2 control-label"><span translate>上级部门</span>：</label>
                        <div class="col-xs-5 wrapper-none">
                            <div class="txt-show p-t-xs">{{detailInfo.parentNodeName}}</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"><i>*</i><span translate>部门名称</span>：</label>
                        <div class="col-xs-5 wrapper-none">
                            <input type="text" name="name" class="form-control" ng-model="detailInfo.departName" required yb-focus maxlength="20">
                        </div>
                        <div class="col-xs-4 msg-block" ng-show="form.name.$dirty || (form.name.$invalid && submitted)">
                            <div class="error-msg" ng-if="form.name.$error.required && !form.name.focused">
                                <i class="yb-icon ico-times-circular"></i><span translate>必填项，请填写</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-5 wrapper-none">
                            <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData(form.$valid)" translate>
                                保存
                            </button>
                            <button type="button" class="btn btn-default" ng-click="changeTab(0)" translate>取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div tab heading="配置仓库" active="activeFlag[3]" ng-if="activeFlag[3]">
            <div class="row wrapper-y-sm form-horizontal ">
                <div class="operate-bar col-xs-5">
                    <label class="col-xs-3 control-label" ><span translate>是否开启仓库控制</span>:</label>
                    <label class="col-xs-9 control-label p-l-n text-left clearfix">
                        <input type="radio" class="m-r-sm pull-left" yb-radio
                                ng-model="warehouseInfo.isEnable" value="1"
                                yb-radio-name="是" yb-click="openOrCloseWarehouse(1)">
                        <input type="radio" class="m-r-sm pull-left" yb-radio
                                ng-model="warehouseInfo.isEnable" value="0"
                                yb-radio-name="否" yb-click="openOrCloseWarehouse(0)">
                        <span translate>（ 温馨提示：选择仓库前，必须先开启仓库控制 ）</span>
                    </label>
                </div>
                <div class="operate-bar col-xs-3">
                    <label class="col-xs-4 control-label"><span translate>仓库控制类型</span>：</label>
                    <label class="col-xs-4 p-l-n text-left clearfix">
                        <select class="form-control txt-search no-pic p-t-xs" ng-model="controlType" ng-change="controlTypeChange(controlType)">
                            <option value='0' translate>库存</option>
                            <option value='1' translate>单据</option>
                        </select>
                    </label>
                    <label class="col-xs-4 p-l-n text-left clearfix" ng-if="controlType==1">
                        <select class="form-control txt-search no-pic p-t-xs" ng-model="billControlType" ng-change="billControlTypeChange(billControlType)">
                            <option value='0'>主库区</option>
                            <option value='1'>次库区</option>
                        </select>
                    </label>
                </div>
            </div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table border-none">
                            <thead>
                            <tr>
                                <th width="40" class="th-check text-center">
                                    <div yb-check-box yb-disabled="warehouseInfo.isEnable==0" yb-checked="warehouseInfo.allChecked" yb-click="selectAll()"></div>
                                </th>
                                <th width="20%" translate>仓库编号</th>
                                <th translate>仓库描述</th>
                                <th width="15%" translate>是否计划仓库</th>
                                <th width="15%" translate>是否中心仓库</th>
                                <th width="15%" translate>是否先入先出</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="myData.length > 0">
                        <table class="table border-none">
                            <tbody>
                            <tr ng-repeat="item in myData track by $index">
                                <td width="40" class="text-center">
                                    <div yb-check-box yb-disabled="warehouseInfo.isEnable==0" yb-checked="item.check"></div>
                                </td>
                                <td width="20%" class="spill-dots" title="{{item.warehouseCode}}">{{item.warehouseCode}}</td>
                                <td class="spill-dots" title="{{item.description}}">{{item.description}}</td>
                                <td width="15%" class="spill-dots" title="{{item.isPlan| TrueOrFalse}}">{{item.isPlan| TrueOrFalse}}</td>
                                <td width="15%" class="spill-dots" title="{{item.isCenter| TrueOrFalse}}">{{item.isCenter| TrueOrFalse}}</td>
                                <td width="15%" class="spill-dots" title="{{item.firstInOut| TrueOrFalse}}">{{item.firstInOut| TrueOrFalse}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="myData.length === 0" translate>暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center border-t clearfix">
                <button type="button" class="btn btn-primary" ng-click="saveWarehouse()" translate>保存</button>
                <button type="button" class="btn btn-default" ng-click="changeTab(0)" translate>取消</button>
            </div>
        </div>
    </div>
</div>